import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import util.ShiroUtils;

/**
 * @author dayu
 * @create 2018/12/11 14:45
 * @Description 连接数据库，判断加密后的密码是否正确登录认证
 */
public class Shiro2 {
    public static void main(String[] args) {
        IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:shiro2/shiro.ini");
        SecurityManager securityManager = factory.getInstance();

        SecurityUtils.setSecurityManager(securityManager);

        Subject subject = SecurityUtils.getSubject();

        UsernamePasswordToken token = new UsernamePasswordToken("dayu", "11");

        ShiroUtils.userLogin(subject, token);


        System.out.println("是否认证：" + subject.isAuthenticated());
        subject.logout();
    }
}
